﻿using System.ComponentModel;
using System.Reflection;

namespace SE.PO.CInterface.Web.Extensions;

public static class EnumExtension
{
    public static Enum ConvertDes2Enum(this string desc,Type type)
    {
        var fields = type.GetFields();
        foreach (var field in fields)
        {
            object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false);    //获取描述属性
            if (objs == null || objs.Length == 0)    //当描述属性没有时，直接返回名称
                return field.;
            DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0];
            if (Equals(descriptionAttribute.Description,desc))
            {
                
            }
            return descriptionAttribute.Description;
        }
        
     
        
    }
}